// pages/reviewRecord/readlist/readlist.js
//获取应用实例
const app = getApp();
const httpUtils = require('../../../utils/httpUtils.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    readList:[],
    imageurl: 'https://yxpmaterial.oss-cn-beijing.aliyuncs.com/',
    task_id:'', //任务id
    sort:'7', //类别
    can_submit: 0, //1 可以提交 0不可以提交
    status:0, //0未复习 1未完成 2已复习
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
     let that =this;
     if(options){
      that.setData({
        task_id: options.task_id,
        sort: options.sort,
        can_submit: options.can_submit,
        status:options.status
      })
     }
     that.getReadList();
  },

  //获取阅读关卡列表
  getReadList(){
    var that = this;
    wx.showLoading({
      title: '',
      mask: true
    })
    httpUtils.getReadReviewList({
      access_token: app.globalData.studentInfo.access_token ? app.globalData.studentInfo.access_token : app.globalData.access_token,
      calendar_id:that.data.task_id,
    }).then((res) => {
      that.setData({
        readList:res.data
      })
  
    });  
  },

  //点击条目跳转阅读作业详情页
  showReadWork(e){
    let that=this;
    let question_id  = e.currentTarget.dataset.id; 
    let calendar_id =e.currentTarget.dataset.calid
    wx.navigateTo({
      url: '/pages/reviewRecord/readwork/readwork?calendar_id='+calendar_id+"&question_id="+question_id+"&sort="+that.data.sort+"&can_submit="+that.data.can_submit+"&status="+that.data.status,
    })
  },

  /**
   * 生命周期数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})